fix(tables): account for letter-spacing and displayed content in column auto-resize#4277
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Auto-resize now formats values based on column type (stringified Reviewed by Cursor Bugbot for commit 5c5b1c5. Configure here. |
Greptile SummaryThis PR fixes column auto-resize under-estimation by (1) mounting the hidden measurement span inside the table container so it inherits Confidence Score: 5/5Safe to merge — targeted bug fix with no risk of regressions. No P0/P1 issues found. The measurement logic is consistent with the actual cell renderers (JSON.stringify for json at line 2775, storageToDisplay at line 2781). The overflow:hidden on the container does not affect getBoundingClientRect().width (layout-level API, not affected by paint clipping). All remaining observations are P2 quality notes. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User double-clicks column resize handle] --> B[handleColumnAutoResize called]
B --> C{column.type === 'boolean'?}
C -- Yes --> D[Return early — checkboxes have fixed width]
C -- No --> E[Get host: containerRef.current ?? document.body]
E --> F[Create hidden span, append to host\ninherits letter-spacing from .workspace-root]
F --> G[Measure column header width\ngetBoundingClientRect width + 57px]
G --> H[For each row value]
H --> I{column.type?}
I -- json --> J[text = JSON.stringify val]
I -- date --> K[text = storageToDisplay val]
I -- other --> L[text = String val]
J & K & L --> M[Measure text width\ngetBoundingClientRect width + 17px]
M --> N[Track maxWidth]
N --> O{More rows?}
O -- Yes --> H
O -- No --> P[newWidth = Math.min ceil maxWidth, 600]
P --> Q[setColumnWidths + persist metadata]
F -->|finally| R[host.removeChild measure span]
Reviews (1): Last reviewed commit: "fix(tables): account for letter-spacing ..." | Re-trigger Greptile |
Summary
.workspace-root'sletter-spacing: 0.02em— previously measured ondocument.body, leading to under-estimated widths and lingering...on some rowsoffsetWidth(rounds down) togetBoundingClientRect().widthfor fractional-pixel accuracyJSON.stringify(val)forjson,storageToDisplay(val)fordate, skipbooleanentirelyType of Change
Testing
Tested manually — double-clicking column resize handle now fits content without ellipsis across text, json, and date columns.
Checklist